package com.controller;

import com.pojo.User;
import com.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/your-consume-url")
public class ConsumptionController {

    @Autowired
    private UserService userService;

    @PostMapping
    public String consume(User user) {
        try {
            userService.triggerRandomConsumption(user);
            return "消费成功";
        } catch (Exception e) {
            return "消费失败: " + e.getMessage();
        }
    }
}